import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:zootix/screens/rank/zt_rank.controller.dart';
import 'package:zootix/store/zt_auth.store.dart';
import 'package:zootix/util/zt_common.util.dart';
import 'package:zootix/util/zt_screen_adaper_util.dart';

import '../../util/zt_util.dart';

class ZtBuyConfirmPopup extends StatelessWidget {
  final _controller = Get.find<ZtRankController>();
  late String parkType;
  ZtBuyConfirmPopup({super.key, required this.parkType});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: ZtScreenAdaper.height(400),
      width: ZtScreenAdaper.width(480),
      padding: EdgeInsets.symmetric(vertical: ZtScreenAdaper.height(10)),
      decoration: BoxDecoration(
          border:
              Border.all(color: Color(0xFFF3AA3B), width: ZtScreenAdaper.sp(5)),
          borderRadius: BorderRadius.circular(30),
          image: DecorationImage(
              fit: BoxFit.cover,
              image: AssetImage('assets/images/rank_buy_popup_bg.png'))),
      child: Column(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ShaderMask(
                  shaderCallback: (Rect bounds) {
                    return const LinearGradient(
                      begin: Alignment.bottomCenter,
                      end: Alignment.topCenter,
                      colors: <Color>[Color(0xFFF3AA3B), Color(0xFFE27613)],
                      tileMode: TileMode.mirror,
                    ).createShader(bounds);
                  },
                  blendMode: BlendMode.srcATop,
                  child: Center(
                    child: Text(
                      'Ticket Purchase',
                      style: TextStyle(
                          fontStyle: FontStyle.italic,
                          fontSize: ZtScreenAdaper.sp(25),
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                )
              ],
            ),
            SizedBox(
              height: ZtScreenAdaper.height(20),
            ),
            Padding(
                padding:
                    EdgeInsets.symmetric(horizontal: ZtScreenAdaper.width(30)),
                child: Row(
                  children: [
                    Text(
                      '${ZtCommonUtil.firstUppercase(parkType)}:',
                      style: TextStyle(fontSize: ZtScreenAdaper.sp(20)),
                    ),
                    Spacer(),
                    Container(
                      padding: EdgeInsets.symmetric(
                          vertical: ZtScreenAdaper.height(2),
                          horizontal: ZtScreenAdaper.width(5)),
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(10),
                          border: Border.all(color: Color(0xFFFFCA41))),
                      child: Row(children: [
                        Image(
                            height: ZtScreenAdaper.height(25),
                            image: AssetImage('assets/images/coin_icon.png')),
                        SizedBox(
                          width: ZtScreenAdaper.width(5),
                        ),
                        Text(
                          '${_controller.ticketPrice}',
                          style: TextStyle(fontSize: ZtScreenAdaper.sp(18)),
                        )
                      ]),
                    )
                  ],
                )),
            Spacer(),
            ElevatedButton(
                style: ElevatedButton.styleFrom(
                    shape: RoundedRectangleBorder(
                        side: BorderSide(color: Colors.white, width: 1),
                        borderRadius:
                            BorderRadius.circular(ZtScreenAdaper.sp(30))),
                    padding: EdgeInsets.symmetric(
                        horizontal: ZtScreenAdaper.height(60),
                        vertical: ZtScreenAdaper.height(10)),
                    backgroundColor: const Color(0xFFFFCA41)),
                onPressed: () {
                  _controller.doPurchase();
                },
                child: Text(
                  'Buy',
                  style: TextStyle(fontSize: ZtScreenAdaper.sp(18)),
                ))
          ]),
    );
  }
}
